package com.noble.glamour.ui.agora.act.voice.girlver;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.noble.glamour.R;
import com.noble.glamour.bean.center.user.detail.UserDetail;
import com.noble.glamour.module.logic.application.ModuleMgr;
import com.noble.glamour.module.logic.baseui.custom.RadiationViewBg;
import com.noble.glamour.ui.agora.model.AgoraConstant;
import com.noble.glamour.ui.agora.model.EngineConfig;
import com.noble.library.image.ImageLoader;
import com.noble.library.utils.ScreenUtils;
import com.noble.library.view.base.BasePanel;

/**
 * 女性任务版： 等待页面头部panel
 * <p>
 * Created by Su on 2017/6/15.
 */
public class RtcInitHeadPanel extends BasePanel {
    private EngineConfig config;
    private RadiationViewBg rvFirst, rvSec;

    public RtcInitHeadPanel(Context context) {
        super(context);
        setContentView(R.layout.f1_chat_init_head_panel);
        initView();
    }

    private void initView() {
        initRadiationView();   // 初始化辐射控件
        config = ModuleMgr.getRtcEnginMgr().getEngineConfig();
        UserDetail userDetail = ModuleMgr.getCenterMgr().getMyInfo();

        ImageView iv_head = (ImageView) findViewById(R.id.iv_head);
        ImageLoader.loadCircleAvatar(getContext(), userDetail.getAvatar(), iv_head);

        if (config.mChatType == AgoraConstant.RTC_CHAT_VIDEO) {
            ImageView chatType = (ImageView) findViewById(R.id.iv_chat_type);
            chatType.setImageResource(R.drawable.f1_chat_video_img);
        }

        // 单聊、群聊
        if (config.mGirlType == AgoraConstant.RTC_CHAT_SINGLE) {
            findViewById(R.id.head_opposite).setVisibility(View.GONE);
        }
    }

    private void initRadiationView() {
        rvFirst = (RadiationViewBg) findViewById(R.id.rv_first);
        rvSec = (RadiationViewBg) findViewById(R.id.rv_sec);
        rvFirst.setDpMultiple(ScreenUtils.toDpMultiple(getActivity()));
        rvSec.setDpMultiple(ScreenUtils.toDpMultiple(getActivity()));

        // 两个控件互相调起
        rvFirst.setRadiationListener(new RadiationViewBg.RadiationListener() {
            @Override
            public void onArrival() {
                rvSec.startRadiate();   // rvSec开启
                if (rvSec.getVisibility() == View.GONE)
                    rvSec.setVisibility(View.VISIBLE);
            }
        });

        rvSec.setRadiationListener(new RadiationViewBg.RadiationListener() {
            @Override
            public void onArrival() {
                rvFirst.startRadiate(); // rvFirst开启
            }
        });
        rvFirst.startRadiate();  // 启动其中之一
    }
}
